package com.bigfreakindeals.Widgets;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigfreakindeals.R;
import com.bigfreakindeals.Application.ApplicationEx;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;

public class MapItemizedOverlay extends ItemizedOverlay<OverlayItem> {
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context mContext;
	Dialog dialog;
	Drawable defaultMarker;
	Point point;
	String companyname = "Epson";
	String dealtitle;
	Bitmap thumbnail;
	
	public MapItemizedOverlay(Drawable defaultMarker, Context context,String company, String title,Bitmap thumbnail) {
		super(boundCenterBottom(defaultMarker));
		mContext = context;
		this.defaultMarker = defaultMarker;
		this.dealtitle = title;
		this.companyname = company;
		this.thumbnail = thumbnail;
	}

	public void addOverlay(OverlayItem overlay) {
		mOverlays.add(overlay);
		populate();
	}

	@Override
	protected OverlayItem createItem(int i) {
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		return mOverlays.size();
	}

	@Override
	protected boolean onTap(int index) {
		if (dialog != null && dialog.isShowing()) {

			dialog.dismiss();
			return true;
		}
		OverlayItem item = mOverlays.get(index);

		// AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
	/*	Dialog dialog = new Dialog(mContext);
		
		dialog.setContentView(R.layout.mapoverlaycompany);
		dialog.setTitle(dealtitle);
		((RelativeLayout) dialog.findViewById(R.id.mapoverlay_companycontainer)).setBackgroundDrawable(ApplicationEx.getInstance().getroundRect());
		
		TextView company = (TextView) dialog.findViewById(R.id.companyname);
		company.setText(companyname);

		ImageView thumb = (ImageView) dialog.findViewById(R.id.adsthumbnail);
		thumb.setImageBitmap(thumbnail);

		dialog.show();

		*/return true;
	}

	

}